package ch07;

class _01_DrawShape {
	public static void main(String[] args) {
		_01_DrawShape shape = new _01_DrawShape();
		shape.paint();
	}

	public void paint() {
		Point[] p = { new Point(100, 100), new Point(140, 50), new Point(200, 100)};
		Triangle t = new Triangle(p);
		Circle c = new Circle(new Point(150, 150), 50);
		System.out.println(t);
		System.out.println(c);
	}	
}

class Point {
	int x;
	int y;

	Point(int x, int y) {
		this.x = x;
		this.y = y;
	}

	Point() {
		this(0,0);
	}
	
	public String toString(){
		return "("+x+","+y+") ";
	}
}

class Circle {
	Point center;
	int r;
	
	Circle() {		
		this(new Point(0, 0), 100);
	}

	Circle(Point center, int r) {
		this.center = center;
		this.r = r;
	}
	
	public String toString(){
		return "[Circle] " + center + r;
	}
}

class Triangle {
	Point[] p = new Point[3];

	Triangle(Point[] p) {
		this.p = p;
	}

	Triangle(Point p1, Point p2, Point p3) {
		p[0] = p1;
		p[1] = p2;
		p[2] = p3;
	}
	
	public String toString(){
		String result = "";
		for(Point tmp:p) result += tmp.toString();
		return "[Triangle] " + result;
	}
}
/*
[Triangle] (100,100) (140,50) (200,100) 
[Circle] (150,150) 50
*/